package org.example.springboot.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.springboot.common.Result;
import org.example.springboot.service.MerchantService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "商户管理接口")
@RestController
@RequestMapping("/merchant")
public class MerchantController {
    private static final Logger LOGGER = LoggerFactory.getLogger(MerchantController.class);

    @Autowired
    private MerchantService merchantService;

    @Operation(summary = "获取商户仪表盘数据")
    @GetMapping("/dashboard")
    public Result<?> getDashboardData(@RequestParam Long merchantId) {
        return merchantService.getDashboardData(merchantId);
    }

    @Operation(summary = "获取商户销售趋势")
    @GetMapping("/sales/trend")
    public Result<?> getSalesTrend(
            @RequestParam Long merchantId,
            @RequestParam(defaultValue = "month") String period) {
        return merchantService.getSalesTrend(merchantId, period);
    }

    @Operation(summary = "获取商户订单状态分布")
    @GetMapping("/orders/status-distribution")
    public Result<?> getOrderStatusDistribution(@RequestParam Long merchantId) {
        return merchantService.getOrderStatusDistribution(merchantId);
    }

    @Operation(summary = "获取商户热销商品")
    @GetMapping("/products/top")
    public Result<?> getTopProducts(
            @RequestParam Long merchantId,
            @RequestParam(defaultValue = "5") Integer limit) {
        return merchantService.getTopProducts(merchantId, limit);
    }

    @Operation(summary = "获取商户待处理事项")
    @GetMapping("/pending-tasks")
    public Result<?> getPendingTasks(@RequestParam Long merchantId) {
        return merchantService.getPendingTasks(merchantId);
    }

    @Operation(summary = "获取商户统计指标")
    @GetMapping("/metrics")
    public Result<?> getMerchantMetrics(@RequestParam Long merchantId) {
        return merchantService.getMerchantMetrics(merchantId);
    }
} 